//
//  AyStatusCell.m
//  xWeibo
//
//  Created by alvis mac on 8/7/15.
//  Copyright (c) 2015 alvis. All rights reserved.
//

#import "AyStatusCell.h"
#import "AyDefine.h"
#import "AyStatusFrame.h"
#import "UIImageExtend.h"
#import "UIImageView+WebCache.h"
#import "AyStatusTopView.h"
#import "AyStatusToolBar.h"
#import "AyDefine.h"
@interface AyStatusCell()
@property (nonatomic, weak) AyStatusTopView *topView;
@property (nonatomic, weak) AyStatusToolBar *statusToolbar;
@end


@implementation AyStatusCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
  static NSString *ID=@"status";
    AyStatusCell *cell=[tableView dequeueReusableCellWithIdentifier:ID];
    if(cell==nil){
        cell=[[AyStatusCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
    }
    return cell;
}

+ (instancetype)cellWithTableViewWithoutToolBar:(UITableView *)tableView{
    AyStatusCell *cell=[self cellWithTableView:tableView];
    cell.statusToolbar.hidden=YES;
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        // 1.添加原创微博内部的子控件
        [self setupTopviews];
        
        // 3.添加微博的工具条
        [self setupStatusToolBar];
        
    }
    return  self;
}

- (void)setupTopviews
{
    // 0.设置cell选中时的背景
    self.selectedBackgroundView = [[UIView alloc] init];
    self.backgroundColor = [UIColor clearColor];
    
    AyStatusTopView *topView = [[AyStatusTopView alloc] init];
    [self.contentView addSubview:topView];
    self.topView = topView;
  
}


- (void)setupStatusToolBar
{
    /** 1.微博的工具条 */
    AyStatusToolBar *statusToolbar = [[AyStatusToolBar alloc] init];
    [self.contentView addSubview:statusToolbar];
    self.statusToolbar = statusToolbar;
}


- (void)setStatusFrame:(AyStatusFrame *)statusFrame{
    _statusFrame=statusFrame;
    self.topView.statusFrame=statusFrame;
    self.statusToolbar.status=statusFrame.status;
    self.topView.frame = self.statusFrame.topViewF;
    self.statusToolbar.frame = self.statusFrame.statusToolbarF;
}



- (void)setFrame:(CGRect)frame{
    frame.origin.y += AyStatusTableBorder;
    frame.origin.x = AyStatusTableBorder;
    frame.size.width -= 2 * AyStatusTableBorder;
    frame.size.height -= AyStatusTableBorder;
    [super setFrame:frame];
}






@end
